package schema

import (
	"context"
	"go-quick/interface/iorm"
	"reflect"
	"time"
)

// special types' reflect type
var (
	TimeReflectType    = reflect.TypeOf(time.Time{})
	TimePtrReflectType = reflect.TypeOf(&time.Time{})
	ByteReflectType    = reflect.TypeOf(uint8(0))
)

// orm time types
const (
	UnixTime        TimeType = 1
	UnixSecond      TimeType = 2
	UnixMillisecond TimeType = 3
	UnixNanosecond  TimeType = 4
)

// orm fields types
const (
	Bool   DataType = "bool"
	Int    DataType = "int"
	Uint   DataType = "uint"
	Float  DataType = "float"
	String DataType = "string"
	Time   DataType = "time"
	Bytes  DataType = "bytes"
)

type (

	// DataType orm data type
	DataType string
	// TimeType orm time type
	TimeType int64

	QField struct {
		Name                   string
		DBName                 string
		BindNames              []string
		DataType               DataType
		GORMDataType           DataType
		PrimaryKey             bool
		AutoIncrement          bool
		AutoIncrementIncrement int64
		Creatable              bool
		Updatable              bool
		Readable               bool
		AutoCreateTime         TimeType
		AutoUpdateTime         TimeType
		HasDefaultValue        bool
		DefaultValue           string
		DefaultValueInterface  any
		NotNull                bool
		Unique                 bool
		Comment                string
		Size                   int
		Precision              int
		Scale                  int
		IgnoreMigration        bool
		FieldType              reflect.Type
		IndirectFieldType      reflect.Type
		StructField            reflect.StructField
		Tag                    reflect.StructTag
		TagSettings            map[string]string
		Schema                 iorm.ISchema
		EmbeddedSchema         iorm.ISchema
		OwnerSchema            iorm.ISchema
		ReflectValueOf         func(context.Context, reflect.Value) reflect.Value
		ValueOf                func(context.Context, reflect.Value) (value interface{}, zero bool)
		Set                    func(context.Context, reflect.Value, interface{}) error
		Serializer             iorm.SerializerInterface
		NewValuePool           iorm.FieldNewValuePool
	}
)
